﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WindowsForms.Admin;
using WindowsForms.PBKT;
using Entities.Admin;
using WindowsForms.TBKN;
using WindowsForms.ThuQuy;
using WindowsForms.PBCM;

namespace WindowsForms
{
	public partial class FormMain : DevComponents.DotNetBar.Office2007RibbonForm
	{
        public static TaiKhoan tkhoan;
         
		public FormMain()
		{
			InitializeComponent();
		}
		public FormMain(TaiKhoan tk)
		{
            tkhoan = tk;
			InitializeComponent();
			if (tk != null)
			{
				int phanQuyen = tk.PhanQuyen;
				SetPhanQuyen(phanQuyen);
				lblUser.Text ="Tên đăng nhập: "+ tk.UserName+ "|Tên nhân viên: "+ tk.TenNhanVien;
			}
		}

		private void SetPhanQuyen(int phanQuyen)
		{
			if (phanQuyen == 1)
			{
			}
			else if (phanQuyen == 2)
			{
				rbquanlihethong.Enabled =
                    rbthuquy.Enabled =
                    rbkhieunai.Enabled =
                rbchuyenmon.Enabled = false;
			}
			else if (phanQuyen == 3)
			{
                rbquanlihethong.Enabled =
                                   rbthuquy.Enabled =
                                   rbkhieunai.Enabled =
                                   rbkythuat.Enabled = false;
			}
			else
				if (phanQuyen == 4)
				{
                    rbquanlihethong.Enabled =
                                   rbkhieunai.Enabled =
                                   rbkythuat.Enabled =
                               rbchuyenmon.Enabled = false;
				}
				else if (phanQuyen == 5)
				{
                    rbquanlihethong.Enabled =
                                   rbthuquy.Enabled =

                                   rbkythuat.Enabled =
                               rbchuyenmon.Enabled = false;
				}
				else
				{
                    rbquanlihethong.Enabled =
                                       rbthuquy.Enabled =
                                       rbkhieunai.Enabled =
                                       rbkythuat.Enabled =
                                   rbchuyenmon.Enabled = false;
				}
		}


		private void bttxemnguoidung_Click(object sender, EventArgs e)
		{
			pnnoidunght.Controls.Clear();
			UcNhanVien dr = new UcNhanVien();
			dr.Dock = System.Windows.Forms.DockStyle.Fill;
			pnnoidunght.Controls.Add(dr);
		}

		private void btThemnd_Click(object sender, EventArgs e)
		{
			//pnnoidunght.Controls.Clear();
			//UcThemNguoiDung dr = new UcThemNguoiDung();
			////dr.Dock = System.Windows.Forms.DockStyle.Fill;

			//pnnoidunght.Controls.Add(dr);
			FormThemNhanVien fr = new FormThemNhanVien();
			fr.ShowDialog();
		}

		private void btxoanguoidung_Click(object sender, EventArgs e)
		{
			FormXoaNguoiDung fr = new FormXoaNguoiDung();
			fr.ShowDialog();
		}

		private void btgioithieu_Click(object sender, EventArgs e)
		{
			AboutBox fr = new AboutBox();
			fr.ShowDialog();
		}

		private void btthemtaikhoan_Click(object sender, EventArgs e)
		{
			pnnoidunght.Controls.Clear();
			UcTaiKhoan dr = new UcTaiKhoan();
			//dr.Dock = System.Windows.Forms.DockStyle.Fill;
			pnnoidunght.Controls.Add(dr);
		}

		private void btquanlitk_Click(object sender, EventArgs e)
		{
			pnnoidunght.Controls.Clear();
			UcDsTaiKhoan dr = new UcDsTaiKhoan();
			dr.Dock = System.Windows.Forms.DockStyle.Fill;
			pnnoidunght.Controls.Add(dr);
		}

		private void btntimkiemtk_Click(object sender, EventArgs e)
		{
			FormTimKiemTaiKhoan fr = new FormTimKiemTaiKhoan();
			fr.ShowDialog();
		}

		private void btnbophan_Click(object sender, EventArgs e)
		{
            pnnoidunght.Controls.Clear();
            UcBoPhan dr = new UcBoPhan();
            //dr.Dock = System.Windows.Forms.DockStyle.Fill;
            pnnoidunght.Controls.Add(dr);
           
		}

		private void bthome_Click(object sender, EventArgs e)
		{
			pnnoidunght.Controls.Clear();
			UcHome dr = new UcHome();
			dr.Dock = System.Windows.Forms.DockStyle.Fill;
			pnnoidunght.Controls.Add(dr);
		}

		private void btnthembp_Click(object sender, EventArgs e)
		{
			FormThemBoPhan fr = new FormThemBoPhan();
			fr.ShowDialog();
		}

		private void btnqlgd_Click(object sender, EventArgs e)
		{
			pnnoidunght.Controls.Clear();
			UcGiaiDau dr = new UcGiaiDau();
			dr.Dock = System.Windows.Forms.DockStyle.Fill;
			pnnoidunght.Controls.Add(dr);
		}

		private void btnreporttk_Click(object sender, EventArgs e)
		{
			FormReportTaiKhoan fr = new FormReportTaiKhoan();
			fr.ShowDialog();
		}

		private void btnLoadLTD_Click(object sender, EventArgs e)
		{
			pnnoidunght.Controls.Clear();
			UCLichThiDau dr = new UCLichThiDau();
			dr.Dock = System.Windows.Forms.DockStyle.Fill;
			pnnoidunght.Controls.Add(dr);
		}

		private void btnLoadDSTrongTai_Click(object sender, EventArgs e)
		{
			pnnoidunght.Controls.Clear();
			UCTrongTai dr = new UCTrongTai();
			dr.Dock = System.Windows.Forms.DockStyle.Fill;
			pnnoidunght.Controls.Add(dr);
		}

		private void btnLoadDSDT_Click(object sender, EventArgs e)
		{
			pnnoidunght.Controls.Clear();
			UCDoiTuyen dr = new UCDoiTuyen();
			dr.Dock = System.Windows.Forms.DockStyle.Fill;
			pnnoidunght.Controls.Add(dr);
		}

		private void btnThemLTD_Click(object sender, EventArgs e)
		{
			using (FormThemTTLichThiDau frm = new FormThemTTLichThiDau(null))
			{
				frm.ShowDialog();
			}
		}

		private void btnTKLichTD_Click(object sender, EventArgs e)
		{
			using (FormTKLichThiDau frm = new FormTKLichThiDau())
			{
				frm.ShowDialog();
			}
		}

		private void btnThemTT_Click(object sender, EventArgs e)
		{
			FormTrongTaiThem frm = new FormTrongTaiThem(null);
			frm.ShowDialog();
		}

		private void btnThemDoiTuyen_Click(object sender, EventArgs e)
		{
			FormDoiTuyenThem frm = new FormDoiTuyenThem(null);
			frm.ShowDialog();
		}
		private void btnTimKiemDT_Click(object sender, EventArgs e)
		{
			FormDoiTuyenTimKiem frm = new FormDoiTuyenTimKiem();
			frm.ShowDialog();
		}
		private void btnTKDT_Click(object sender, EventArgs e)
		{
			FormDoiTuyenThongKe frm = new FormDoiTuyenThongKe();
			frm.ShowDialog();
		}

		private void btTKCT_Click(object sender, EventArgs e)
		{
			FormDoiTuyenTKCauThu frm = new FormDoiTuyenTKCauThu();
			frm.ShowDialog();
		}

		private void btnTKDoiVoDich_Click(object sender, EventArgs e)
		{
			FormDoiTuyenTKDoiTuyen frm = new FormDoiTuyenTKDoiTuyen();
			frm.ShowDialog();
		}
		private void btndangxuat_Click(object sender, EventArgs e)
		{
			this.Close();
			//this.Parent.Visible = true;
		}

        private void btnketqua_Click(object sender, EventArgs e)
        {
            FormDoiTuyen fr = new FormDoiTuyen();
            fr.ShowDialog();
        }

        private void btngidau_Click(object sender, EventArgs e)
        {
            pnnoidunght.Controls.Clear();
            UcGiaiDau dr = new UcGiaiDau();
            dr.Dock = System.Windows.Forms.DockStyle.Fill;
            pnnoidunght.Controls.Add(dr);
        }

        private void btnthaydoi_Click(object sender, EventArgs e)
        {
            FormThayDoiThongTin.taikhoan = tkhoan;
            FormThayDoiThongTin fr = new FormThayDoiThongTin();
            fr.FormClosed += new FormClosedEventHandler(fr_FormClosed);
            fr.ShowDialog();
        }

        void fr_FormClosed(object sender, FormClosedEventArgs e)
        {
            lblUser.Text = "Tên đăng nhập: " + FormThayDoiThongTin.tenus + "|Tên nhân viên: " + tkhoan.TenNhanVien;
        }

        private void btnkq_Click(object sender, EventArgs e)
        {
            FormDsKetQua fr = new FormDsKetQua();
            fr.Show();
        }

        private void btnHoaDon_Click(object sender, EventArgs e)
        {
            FormHoaDon frm = new FormHoaDon();
            frm.ShowDialog();
        }

        private void btnBaoCao_Click(object sender, EventArgs e)
        {
            FormBaoCao frm = new FormBaoCao();
            frm.ShowDialog();
        }

        private void labelItem1_Click(object sender, EventArgs e)
        {

        }

        private void btnKhieuNai_Click(object sender, EventArgs e)
        {
            FormKhieuNai frm = new FormKhieuNai();
            frm.ShowDialog();
        }

        private void buttonItemPBCN_Click(object sender, EventArgs e)
        {
            FormPhoBanChuyenMon ga = new FormPhoBanChuyenMon();
            ga.ShowDialog();
        }


	}
}
